const express = require('express');
const router = express.Router();
const mysql = require('mysql')
const db = require('../../sql/db')
const $sql = require('../../sql/sqlMap')

const connection = mysql.createConnection(db.mysql,);
connection.connect();
const sql = $sql.management.getAllApply;

router.get('/:id', (req, res, next) => {
    connection.query(sql, [req.params.id], (err, result) => {
        if (err) {
            console.log(err)
            return
        }
        for (let i = 0; i < result.length; i++) {

            result[i].ChildObject = [{
                creditNumber: result[i].creditNumber,
                reason: result[i].reason,
                pic_path: result[i].pic_path,
                apply_Time: result[i].apply_Time,
                judge_Time: result[i].judge_Time
            }];
        }
        res.json({
            status: '0',
            msg: '获取本班学分申请记录',
            result: result
        })
    })

});

module.exports = router;
